package com.bw.spark02.rdd.transformation

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}


object RDD_28_flatMapValues {
    
    def main(args: Array[String]): Unit = {
    
        // 初始化编程入口
        val sparkConf = new SparkConf()
        sparkConf.setMaster("local")
        sparkConf.setAppName("RDD_Test")
        val sc = new SparkContext(sparkConf)
    
        val rdd: RDD[String] = sc.parallelize(List("dog", "tiger", "lion", "cat", "panther", "eagle"), 2)
        val rdd2 = rdd.map(x => (x.length, x))
        rdd2.foreach(x => println(x))
    
        /**
         * TODO
         */
        rdd2.flatMapValues("x" + _ + "x").foreach(println)
    }
}
